package arocms.upload;

import arocms.Constans;
import arocms.business.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

import org.apache.log4j.*;

public class FileDetailsAction extends Action {
    
    private final static String SUCCESS = "success";
    private final static String FAILURE = "failure";
    private static Logger log = Logger.getLogger(FileDetailsAction.class);
    
    public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        String sid = request.getParameter("id");
        if (sid==null) { 
             log.error("No id parameter found in request");
             return mapping.findForward(FAILURE);
        }
        Long id = new Long(sid);
        FileDetails fd = new FileDAO().findFileDetails(id);
        request.setAttribute(Constans.FILE_DETAILS_PATH,fd);
        return mapping.findForward(SUCCESS);
    }
}
